home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1996-05-01 | 18.8 KB | 481 lines | [ TEXT/MPS ]
{ File: AppleEvents.p Contains: AppleEvent Package Interfaces. Version: Technology: System 7.5 Release: Universal Interfaces 3.0d3 on Copland DR1 Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved. Bugs?: If you find a problem with this file, send the file and version information (from above) and the problem description to: Internet: apple.bugs@applelink.apple.com AppleLink: APPLE.BUGS } {$IFC UNDEFINED UsingIncludes} {$SETC UsingIncludes := 0} {$ENDC} {$IFC NOT UsingIncludes} UNIT AppleEvents; INTERFACE {$ENDC} {$IFC UNDEFINED __APPLEEVENTS__} {$SETC __APPLEEVENTS__ := 1} {$I+} {$SETC AppleEventsIncludes := UsingIncludes} {$SETC UsingIncludes := 1} {$IFC UNDEFINED __TYPES__} {$I Types.p} {$ENDC} {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED } {$IFC NOT FOR_PTR_BASED_AE } {$IFC UNDEFINED __MEMORY__} {$I Memory.p} {$ENDC} {$IFC UNDEFINED __MIXEDMODE__} {$I MixedMode.p} {$ENDC} {$IFC UNDEFINED __NOTIFICATION__} {$I Notification.p} {$ENDC} {$IFC UNDEFINED __EVENTS__} {$I Events.p} {$ENDC} {$ENDC} {$ENDC} {$IFC FOR_SYSTEM8_PREEMPTIVE } {$IFC UNDEFINED __KERNEL__} {$I Kernel.p} {$ENDC} {$ENDC} {$IFC UNDEFINED __AEDATAMODEL__} {$I AEDataModel.p} {$ENDC} {$PUSH} {$ALIGN MAC68K} {$LibExport+} CONST { Keywords for Apple event parameters } keyDirectObject = '----'; keyErrorNumber = 'errn'; keyErrorString = 'errs'; keyProcessSerialNumber = 'psn '; { Keywords for special handlers } keyPreDispatch = 'phac'; { preHandler accessor call } keySelectProc = 'selh'; { more selector call } { Keyword for recording } keyAERecorderCount = 'recr'; { available only in vers 1.0.1 and greater } { Keyword for version information } keyAEVersion = 'vers'; { available only in vers 1.0.1 and greater } { Event Class } kCoreEventClass = 'aevt'; { Event ID’s } kAEOpenApplication = 'oapp'; kAEOpenDocuments = 'odoc'; kAEPrintDocuments = 'pdoc'; kAEQuitApplication = 'quit'; kAEAnswer = 'ansr'; kAEApplicationDied = 'obit'; { Constants for recording } kAEStartRecording = 'reca'; { available only in vers 1.0.1 and greater } kAEStopRecording = 'recc'; { available only in vers 1.0.1 and greater } kAENotifyStartRecording = 'rec1'; { available only in vers 1.0.1 and greater } kAENotifyStopRecording = 'rec0'; { available only in vers 1.0.1 and greater } kAENotifyRecording = 'recr'; { available only in vers 1.0.1 and greater } {$IFC FOR_SYSTEM8_PREEMPTIVE } {$IFC FOR_PTR_BASED_AE } TYPE AEDispatcherID = ^LONGINT; AEDispatcherRef = ^LONGINT; AEHandlerTableRef = ^LONGINT; AEDelayedSendRef = ^LONGINT; { this will be removed by D11E3 or earlier (!!!) } AEHandlerTable = AEHandlerTableRef; AEReceiveMode = OptionBits; CONST kAEReceiveForever = $00000000; kAEReceiveOneEvent = $00000001; kAEReceiveUntilUnhandledEvent = $00000002; {$ENDC} {$ENDC} { parameter to AESend } TYPE AESendOptions = OptionBits; CONST kAENeverInteract = $00000010; { server should not interact with user } kAECanInteract = $00000020; { server may try to interact with user } kAEAlwaysInteract = $00000030; { server should always interact with user where appropriate } kAECanSwitchLayer = $00000040; { interaction may switch layer } kAEDontRecord = $00001000; { don't record this event - available only in vers 1.0.1 and greater } kAEDontExecute = $00002000; { don't send the event for recording - available only in vers 1.0.1 and greater } kAEProcessNonReplyEvents = $00008000; { allow processing of non-reply events while awaiting synchronous AppleEvent reply } {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED } {$IFC NOT FOR_PTR_BASED_AE } TYPE AESendMode = SInt32; CONST kAENoReply = $00000001; { sender doesn't want a reply to event } kAEQueueReply = $00000002; { sender wants a reply but won't wait } kAEWaitReply = $00000003; { sender wants a reply and will wait } kAEDontReconnect = $00000080; { don't reconnect if there is a sessClosedErr from PPCToolbox } kAEWantReceipt = $00000200; { (nReturnReceipt) sender wants a receipt of message } {$ENDC} {$ENDC} { Constants for timeout durations } kAEDefaultTimeout = -1; { timeout value determined by AEM } kNoTimeOut = -2; { wait until reply comes back, however long it takes } { priority param of AESend } TYPE AESendPriority = SInt16; CONST kAENormalPriority = $00000000; { post message at the end of the event queue } kAEHighPriority = $00000001; { post message at the front of the event queue (same as nAttnMsg) } TYPE AEEventSource = SInt8; CONST kAEUnknownSource = 0; kAEDirectCall = 1; kAESameProcess = 2; kAELocalProcess = 3; kAERemoteProcess = 4; {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED } {$IFC NOT FOR_PTR_BASED_AE } TYPE AEEventHandlerProcPtr = ProcPtr; { FUNCTION AEEventHandler((CONST)VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; handlerRefcon: UInt32): OSErr; } AEIdleProcPtr = ProcPtr; { FUNCTION AEIdle(VAR theEvent: EventRecord; VAR sleepTime: LONGINT; VAR mouseRgn: RgnHandle): BOOLEAN; } AEFilterProcPtr = ProcPtr; { FUNCTION AEFilter(VAR theEvent: EventRecord; returnID: LONGINT; transactionID: LONGINT; (CONST)VAR sender: AEAddressDesc): BOOLEAN; } AEEventHandlerUPP = UniversalProcPtr; AEIdleUPP = UniversalProcPtr; AEFilterUPP = UniversalProcPtr; CONST uppAEEventHandlerProcInfo = $00000FE0; uppAEIdleProcInfo = $00000FD0; uppAEFilterProcInfo = $00003FD0; FUNCTION NewAEEventHandlerProc(userRoutine: AEEventHandlerProcPtr): AEEventHandlerUPP; {$IFC NOT GENERATINGCFM } INLINE $2E9F; {$ENDC} FUNCTION NewAEIdleProc(userRoutine: AEIdleProcPtr): AEIdleUPP; {$IFC NOT GENERATINGCFM } INLINE $2E9F; {$ENDC} FUNCTION NewAEFilterProc(userRoutine: AEFilterProcPtr): AEFilterUPP; {$IFC NOT GENERATINGCFM } INLINE $2E9F; {$ENDC} FUNCTION CallAEEventHandlerProc({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; handlerRefcon: UInt32; userRoutine: AEEventHandlerUPP): OSErr; {$IFC NOT GENERATINGCFM} INLINE $205F, $4E90; {$ENDC} FUNCTION CallAEIdleProc(VAR theEvent: EventRecord; VAR sleepTime: LONGINT; VAR mouseRgn: RgnHandle; userRoutine: AEIdleUPP): BOOLEAN; {$IFC NOT GENERATINGCFM} INLINE $205F, $4E90; {$ENDC} FUNCTION CallAEFilterProc(VAR theEvent: EventRecord; returnID: LONGINT; transactionID: LONGINT; {CONST}VAR sender: AEAddressDesc; userRoutine: AEFilterUPP): BOOLEAN; {$IFC NOT GENERATINGCFM} INLINE $205F, $4E90; {$ENDC} {$ENDC} {$ENDC} {$IFC FOR_SYSTEM8_PREEMPTIVE } {$IFC FOR_PTR_BASED_AE } TYPE AEEventHandlerProc = ProcPtr; { FUNCTION AEEventHandlerProc((CONST)VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; handlerRefcon: UNIV Ptr; handlerTable: AEHandlerTableRef): OSStatus; C; } {$ENDC} {$ENDC} {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED } {$IFC NOT FOR_PTR_BASED_AE } { ************************************************************************* The next couple of calls are basic routines used to create, send, and process AppleEvents. ************************************************************************* } FUNCTION AESend({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $0D17, $A816; {$ENDC} FUNCTION AEProcessAppleEvent({CONST}VAR theEventRecord: EventRecord): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $021B, $A816; {$ENDC} {$ENDC} {$ENDC} {$IFC FOR_SYSTEM8_PREEMPTIVE } {$IFC FOR_PTR_BASED_AE } { ************************************************************************* The next set of calls are basic routines used to send and process AppleEvents. ************************************************************************* } { the reply param MUST be created by the caller if a reply is requested otherwise, the caller must specify nil, or a NULL AppleEvent, if no reply is requested } FUNCTION AESendEvent({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendOpts: AESendOptions; sendPriority: AESendPriority; timeoutDuration: Duration): OSStatus; C; FUNCTION AESendEventQueueReply({CONST}VAR theAppleEvent: AppleEvent; {CONST}VAR replyAddress: AEAddressDesc; sendOpts: AESendOptions; sendPriority: AESendPriority): OSStatus; C; { the reply param MUST be created by the caller if a reply is requested otherwise, the caller must specify nil, or a NULL AppleEvent, if no reply is requested } FUNCTION AESendEventToSelf({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; whichDispatcher: AEDispatcherRef; sendOpts: AESendOptions): OSStatus; C; FUNCTION AESendDelayed({CONST}VAR theAppleEvent: AppleEvent; delayForSend: Duration; VAR delayedSend: AEDelayedSendRef): OSStatus; C; FUNCTION AECancelDelayedSend(delayedSend: AEDelayedSendRef): OSStatus; C; { ************************************************************************* The next couple of calls are for causing kernel asynchronous completion notifications to send an AppleEvent when they fire. ************************************************************************* } FUNCTION AECreateNotifier({CONST}VAR theAppleEvent: AppleEvent; VAR theNotification: KernelNotification): OSStatus; C; FUNCTION AEDisposeNotifier({CONST}VAR theNotification: KernelNotification): OSStatus; C; {$ENDC} {$ENDC} { Note: during event processing, an event handler may realize that it is likely to exceed the client's timeout limit. Passing the reply to this routine causes a wait event to be generated that asks the client for more time. } {$IFC FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE } FUNCTION AEResetTimer({CONST}VAR reply: AppleEvent): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $0219, $A816; {$ENDC} {$ENDC} { ************************************************************************* The following three calls are used to allow applications to behave courteously when a user interaction such as a dialog box is needed. ************************************************************************* } {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE } TYPE AEInteractAllowed = SInt8; CONST kAEInteractWithSelf = 0; kAEInteractWithLocal = 1; kAEInteractWithAll = 2; FUNCTION AEGetInteractionAllowed(VAR level: AEInteractAllowed): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $021D, $A816; {$ENDC} FUNCTION AESetInteractionAllowed(level: AEInteractAllowed): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $011E, $A816; {$ENDC} {$ENDC} {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED } {$IFC NOT FOR_PTR_BASED_AE } FUNCTION AEInteractWithUser(timeOutInTicks: LONGINT; nmReqPtr: NMRecPtr; idleProc: AEIdleUPP): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $061C, $A816; {$ENDC} {$ENDC} {$ENDC} {$IFC FOR_SYSTEM8_PREEMPTIVE } {$IFC FOR_PTR_BASED_AE } { ************************************************************************* These calls are used to create and dispose Apple event handler tables, as well as to install, get and remove handlers from them. ************************************************************************* } FUNCTION AENewHandlerTable(VAR newTable: AEHandlerTableRef; refCon: UNIV Ptr): OSStatus; C; FUNCTION AENewFilterHandlerTable(VAR newTable: AEHandlerTableRef; refCon: UNIV Ptr): OSStatus; C; FUNCTION AEShareHandlerTable(table: AEHandlerTableRef; newRefcon: UNIV Ptr; VAR newSharedReference: AEHandlerTableRef): OSStatus; C; FUNCTION AEDisposeHandlerTable(table: AEHandlerTableRef): OSStatus; C; FUNCTION AEGetHandlerTableRefCon(table: AEHandlerTableRef; VAR refCon: UNIV Ptr): OSStatus; C; FUNCTION AEInstallHandler(table: AEHandlerTableRef; handlerClass: AEEventClass; handlerID: AEEventID; handler: AEEventHandlerProc; handlerRefcon: UNIV Ptr): OSStatus; C; FUNCTION AERemoveHandler(table: AEHandlerTableRef; handlerClass: AEEventClass; handlerID: AEEventID; handler: AEEventHandlerProc): OSStatus; C; FUNCTION AEGetHandler(table: AEHandlerTableRef; handlerClass: AEEventClass; handlerID: AEEventID; VAR handler: AEEventHandlerProc; VAR handlerRefcon: UNIV Ptr): OSStatus; C; { ************************************************************************* These calls are used to setup and get events from Apple event dispatchers. ************************************************************************* } FUNCTION AEGetDefaultDispatcher: AEDispatcherRef; C; FUNCTION AECreateEventDispatcher(VAR newDispatcher: AEDispatcherRef; allocator: MemAllocatorRef): OSStatus; C; FUNCTION AEDisposeEventDispatcher(deadDispatcher: AEDispatcherRef): OSStatus; C; FUNCTION AEGetEventDispatcherID(dispatcher: AEDispatcherRef; VAR globalIdentity: AEDispatcherID): OSStatus; C; FUNCTION AEPushDispatcherHandlerTable(dispatcher: AEDispatcherRef; table: AEHandlerTableRef): OSStatus; C; FUNCTION AEPopDispatcherHandlerTable(dispatcher: AEDispatcherRef; VAR table: AEHandlerTableRef): OSStatus; C; FUNCTION AEGetDispatcherTopHandlerTable(dispatcher: AEDispatcherRef; VAR table: AEHandlerTableRef): OSStatus; C; FUNCTION AEReceive(waitDispatcher: AEDispatcherRef; receiveMode: AEReceiveMode): OSStatus; C; {$ENDC} {$ENDC} {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED } {$IFC NOT FOR_PTR_BASED_AE } { ************************************************************************* These calls are used to set up and modify the event dispatch table. ************************************************************************* } FUNCTION AEInstallEventHandler(theAEEventClass: AEEventClass; theAEEventID: AEEventID; handler: AEEventHandlerUPP; handlerRefcon: LONGINT; isSysHandler: BOOLEAN): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $091F, $A816; {$ENDC} FUNCTION AERemoveEventHandler(theAEEventClass: AEEventClass; theAEEventID: AEEventID; handler: AEEventHandlerUPP; isSysHandler: BOOLEAN): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $0720, $A816; {$ENDC} FUNCTION AEGetEventHandler(theAEEventClass: AEEventClass; theAEEventID: AEEventID; VAR handler: AEEventHandlerUPP; VAR handlerRefcon: LONGINT; isSysHandler: BOOLEAN): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $0921, $A816; {$ENDC} { ************************************************************************* The following four calls are available for applications which need more sophisticated control over when and how events are processed. Applications which implement multi-session servers or which implement their own internal event queueing will probably be the major clients of these routines. They can be called from within a handler to prevent the AEM from disposing of the AppleEvent when the handler returns. They can be used to asynchronously process the event (as MacApp does). ************************************************************************* } FUNCTION AESuspendTheCurrentEvent({CONST}VAR theAppleEvent: AppleEvent): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $022B, $A816; {$ENDC} { Note: The following routine tells the AppleEvent manager that processing is either about to resume or has been completed on a previously suspended event. The procPtr passed in as the dispatcher parameter will be called to attempt to redispatch the event. Several constants for the dispatcher parameter allow special behavior. They are: - kAEUseStandardDispatch means redispatch as if the event was just received, using the standard AppleEvent dispatch mechanism. - kAENoDispatch means ignore the parameter. Use this in the case where the event has been handled and no redispatch is needed. - non nil means call the routine which the dispatcher points to. } { Constants for Refcon in AEResumeTheCurrentEvent with kAEUseStandardDispatch } CONST kAEDoNotIgnoreHandler = $00000000; kAEIgnoreAppPhacHandler = $00000001; { available only in vers 1.0.1 and greater } kAEIgnoreAppEventHandler = $00000002; { available only in vers 1.0.1 and greater } kAEIgnoreSysPhacHandler = $00000004; { available only in vers 1.0.1 and greater } kAEIgnoreSysEventHandler = $00000008; { available only in vers 1.0.1 and greater } kAEIngoreBuiltInEventHandler = $00000010; { available only in vers 1.0.1 and greater } kAEDontDisposeOnResume = $80000000; { available only in vers 1.0.1 and greater } { Constants for AEResumeTheCurrentEvent } kAENoDispatch = 0; { dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch } kAEUseStandardDispatch = $FFFFFFFF; { table, or one of these two constants } FUNCTION AEResumeTheCurrentEvent({CONST}VAR theAppleEvent: AppleEvent; {CONST}VAR reply: AppleEvent; dispatcher: AEEventHandlerUPP; handlerRefcon: LONGINT): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $0818, $A816; {$ENDC} FUNCTION AEGetTheCurrentEvent(VAR theAppleEvent: AppleEvent): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $021A, $A816; {$ENDC} FUNCTION AESetTheCurrentEvent({CONST}VAR theAppleEvent: AppleEvent): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $022C, $A816; {$ENDC} {$ENDC} {$ENDC} { ************************************************************************* These calls are used to set up and modify special hooks into the AppleEvent manager. ************************************************************************* } {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED } {$IFC NOT FOR_PTR_BASED_AE } FUNCTION AEInstallSpecialHandler(functionClass: AEKeyword; handler: UniversalProcPtr; isSysHandler: BOOLEAN): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $0500, $A816; {$ENDC} FUNCTION AERemoveSpecialHandler(functionClass: AEKeyword; handler: UniversalProcPtr; isSysHandler: BOOLEAN): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $0501, $A816; {$ENDC} FUNCTION AEGetSpecialHandler(functionClass: AEKeyword; VAR handler: UniversalProcPtr; isSysHandler: BOOLEAN): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $052D, $A816; {$ENDC} {$ENDC} {$ENDC} {$IFC FOR_SYSTEM8_PREEMPTIVE } {$IFC FOR_PTR_BASED_AE } FUNCTION AEInstallSpecialCallback(dispatcher: AEDispatcherRef; functionClass: AEKeyword; handler: ProcPtr): OSStatus; C; FUNCTION AERemoveSpecialCallback(dispatcher: AEDispatcherRef; functionClass: AEKeyword; handler: ProcPtr): OSStatus; C; FUNCTION AEGetSpecialCallback(dispatcher: AEDispatcherRef; functionClass: AEKeyword; VAR handler: ProcPtr): OSStatus; C; {$ENDC} {$ENDC} { ************************************************************************* This call was added in version 1.0.1. If called with the keyword keyAERecorderCount ('recr'), the number of recorders that are currently active is returned in 'result' (available only in vers 1.0.1 and greater). ************************************************************************* } {$IFC FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE } FUNCTION AEManagerInfo(keyWord: AEKeyword; VAR result: LONGINT): OSErr; {$IFC NOT GENERATINGCFM} INLINE $303C, $0441, $A816; {$ENDC} {$ENDC} {$ALIGN RESET} {$POP} {$SETC UsingIncludes := AppleEventsIncludes} {$ENDC} {__APPLEEVENTS__} {$IFC NOT UsingIncludes} END. {$ENDC}